﻿#ifndef INFFILE_H
#define INFFILE_H

#include <windows.h>
#include <SetupAPI.h>

class InfFile {
public:
    struct InfFileField {
        const char *pSection;
        const char *pKey;
        int         nField;
        const char *pFieldValue;
    };

    struct InfFileUninstall {
        const InfFile::InfFileField *pRequiredFields;
        bool queryConfirmation;
    };

public:
    InfFile(const char *pInfName, const char *pNearPath);
    ~InfFile();

    bool Test(const InfFileField *pFields, bool showErrors = true) const;

    const char *Path() const { return pPath; }
    const char *OemPath(bool showErrors = true) const;
    const char *ClassGUID(bool showErrors = true) const;
    const char *Class(bool showErrors = true) const;
    const char *Provider(bool showErrors = true) const;
    const char *DriverVer(bool showErrors = true) const;
    const char *UninstallInfTag(bool showErrors = true) const;

    bool UninstallFiles(const char *pFilesSection) const;

    bool InstallOEMInf() const;
    bool UninstallOEMInf() const;

    static bool UninstallAllInfFiles(
        const InfFileUninstall *pInfFileUninstallList,
        const char *const *ppOemPathExcludeList);

protected:
    char *pPath;
    mutable char *pOemPath;
    mutable char *pClassGUID;
    mutable char *pClass;
    mutable char *pProvider;
    mutable char *pDriverVer;
    mutable char *pUninstallInfTag;
    mutable HINF hInf;
};

#endif // INFFILE_H
